var express = require('express');
var router = express.Router();
var usersCtl = require("../controds/user");
var commentsCtl = require("../controds/comments");
var likesCyl = require("../controds/likes");
var listensCtl = require("../controds/listens");
var multer = require("multer");

//配置multer
const storage1 = multer.diskStorage({
    destination:function(req,file,callback){
        callback(null,"public/newusers");//设置上传的目录，public/images必须事先存在
    },
    filename:function(req,file,callback){
        callback(null,file.originalname);
    }
  })
  const upload1 = multer({
    storage:storage1,
    limits:6*1024*1024
  })
  const storage2 = multer.diskStorage({
    destination:function(req,file,callback){
        callback(null,"public/newImages");//设置上传的目录，public/images必须事先存在
    },
    filename:function(req,file,callback){
        callback(null,file.originalname);
    }
  })
  const upload2 = multer({
    storage:storage2,
    limits:6*1024*1024
  })

//登录
router.post("/login",usersCtl.login);

//管理员登录
router.post("/adminLogin",usersCtl.adminLogin);

//注册
router.post("/regist",usersCtl.regist);

//点歌单
router.get("/dotSongList",listensCtl.dotSongList);

//歌曲写评论
router.get("/songWrite",commentsCtl.songWrite);

//歌单写评论
router.get("/songListWrite",commentsCtl.songListWrite);

//歌曲删评论
router.get("/songDelete2",commentsCtl.songDelete);

//歌单删评论
router.get("/songListDelete",commentsCtl.songListDelete);

//收藏歌曲
router.get("/songLike",likesCyl.songLike);

//收藏歌单
router.get("/songListLike",likesCyl.songListLike);

//取消收藏歌曲
router.get("/songCancel",likesCyl.songCancel);

//取消收藏歌单
router.get("/songListCancel",likesCyl.songListCancel);

//收藏全部歌曲
router.get("/songLikes",likesCyl.songLikes);

//收藏全部歌单
router.get("/songListLikes",likesCyl.songListlikes);

//全部用户数据
router.get("/usersAll",usersCtl.usersAll);

//全部歌曲数据
router.get("/songsAll",usersCtl.songsAll);

//全部歌单数据
router.get("/songListsAll",usersCtl.songListsAll);

//删除用户
router.get("/usersDelete",usersCtl.usersDelete);

//点击用户
router.get("/userDot",usersCtl.userDot);

//编辑用户
router.post("/userRedact",upload1.single("users1"),usersCtl.userRedact);

//个人中心
router.get("/personalCenter",usersCtl.personalCenter);

//编辑个人中心
router.post("/personalCenterRedact",upload1.single("ImgUrl"),usersCtl.personalCenterRedact);

//编辑歌曲
router.post("/songRedact",upload2.array("songs",2),usersCtl.songRedact);

//删除歌曲
router.get("/songDelete1",usersCtl.songDelete);

//删除歌曲评论
router.get("/songCD",usersCtl.songCommentDelete);

//删除歌单评论
router.get("/songListCD",usersCtl.songListCommentDelete);

module.exports = router;
